package api.Cuisines;
import DAO.Cuisine;
import club.kingon.sql.builder.SqlBuilder;
import club.kingon.sql.builder.enums.Operator;
import util.DBConnector;
import util.StanderRES;

import java.util.List;

public class ImplUseCuisines implements UseCuisines {
    @Override
    public String getAllCuisines() {
        List<Cuisine> result = DBConnector.result((C) -> C.createQuery(SqlBuilder.selectAll().from(Cuisine.class).build()).executeAndFetch(Cuisine.class));
        return StanderRES.RES(StanderRES.Status.OK, result);
    }

    @Override
    public String getCuisines(String id) {
        List<Cuisine> result = DBConnector.result(C -> C.createQuery(SqlBuilder.selectAll().from(Cuisine.class).where(Cuisine::getId,Operator.EQ,id).build()).executeAndFetch(Cuisine.class));
        return StanderRES.RES(StanderRES.Status.OK, result);
    }
}
